﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Hetang.Controllers
{
    public class DataController : Controller
    {
        //
        // GET: /Data/

        public ActionResult Js(string j)
        {
            if (System.Text.RegularExpressions.Regex.IsMatch(j, @"\w+.js"))
            {
                string path = Server.MapPath("~/Data/js/" + j);
                if (System.IO.File.Exists(path))
                    return base.File(path, "application/x-javascript");
                else
                    return base.File(Server.MapPath("~/Data/404.txt"), "text/plain");
            }
            else
            {
                return base.File(Server.MapPath("~/Data/404.txt"), "text/plain");
            }
        }

        public ActionResult Css(string c)
        {
            if (System.Text.RegularExpressions.Regex.IsMatch(c, @"\w+.css"))
            {
                string path = Server.MapPath("~/Data/css/" + c);
                if (System.IO.File.Exists(path))
                    return base.File(path, "text/css");
                else
                    return base.File(Server.MapPath("~/Data/404.txt"), "text/plain");
            }
            else
            {
                return base.File(Server.MapPath("~/Data/404.txt"), "text/plain");
            }
        }

    }
}
